package internal

import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/jianfengye/collection"
	"github.com/kakuilan/kgo"
	_ "github.com/kakuilan/kgo"
	"github.com/shopspring/decimal"
	"math/rand"
	db1 "server/libs/db"
	"server/libs/log"
	"server/msg/pb"
	"strconv"
	"strings"
	"sync"
)

type Generate struct {
}

func NewGenerate() *Generate {
	return &Generate{}
}

// var rewardsTable = [10][10]float32{}
// var sumRewards = make(map[int8]float32, 17)
// var totalIncome float32
var combArray [][]int8
var mutex sync.Mutex

func isConsecutive(nums []int8) bool {
	for i := 0; i < len(nums)-3; i++ {
		if nums[i]+1 == nums[i+1] && nums[i+1]+1 == nums[i+2] && nums[i+2]+1 == nums[i+3] {
			return true
		} else if nums[i]-1 == nums[i+1] && nums[i+1]-1 == nums[i+2] && nums[i+2]-1 == nums[i+3] {
			return true
		}
	}
	return false
}

// 生成数字的排列组合
func permutations(nums []int8) [][]int8 {
	var result [][]int8
	var backtrack func(int)
	backtrack = func(first int) {
		if len(nums) == first {
			temp := make([]int8, len(nums))
			copy(temp, nums)
			if !isConsecutive(temp) {
				result = append(result, temp)
			}
			return
		}
		for i := first; i < len(nums); i++ {
			nums[first], nums[i] = nums[i], nums[first]
			backtrack(first + 1)
			nums[first], nums[i] = nums[i], nums[first]
		}
	}
	backtrack(0)
	return result
}

// 根据马匹排名计算  总奖励价值的功能
func calculateTotalReward(target []int8, total float32, rewards [10][10]float32, sumRewards map[int8]float32) float32 {
	var totalReward float32 = 0.00
	for index, horsesNo := range target {
		reward := rewards[horsesNo-1][index]
		totalReward += reward
		//总奖励大于总的收入,新策略有问题已经修改
		if totalReward > total {
			return totalReward
		}
	}
	// 冠亚和赔付金额加进去
	key := target[0] + target[1]
	if addReward, ok := sumRewards[key]; ok {
		totalReward += addReward
	}
	return totalReward
}

// 查找总奖励在给定范围内的排列的函数
func findInRange(combos [][]int8, total float32, //排列组合 总投注金额
	rewards [10][10]float32, sumRewards map[int8]float32, //单号奖励 冠亚和奖励
	min int, max int, lft int, rgt int) (results [][]int8) { //杀率配置4个参数
	results = [][]int8{}
	log.Logs().Info("总收入", total, "组合大小:", len(combos), min, max, lft, rgt)
	log.Logs().Info("单号码奖励出去金额", rewards)
	log.Logs().Info("冠亚和奖励出去金额", sumRewards)
	for i := 0; i < 100; i++ {
		for _, target := range combos {
			// total是平台当前收益的金额
			minRewards := total * (1 - float32(min-lft*i)/float32(100)) //95 100 105 105 110
			maxRewards := total * (1 - float32(max+rgt*i)/float32(100)) //90 85 80  95  90

			// 增加的如果为负数的情况设置0
			if minRewards < 0.00 {
				minRewards = 0.00
			}
			if maxRewards < 0.00 {
				maxRewards = 0.00
			}

			//这里注意没人下注的情况，都是0默认3567292个
			//如果在范围内就放进数据库再筛选，map，redis
			if maxRewards >= minRewards {
				//当前组合总共的奖励出去的金额
				totalReward := calculateTotalReward(target, maxRewards, rewards, sumRewards)
				if totalReward >= minRewards && totalReward <= maxRewards {
					results = append(results, target)
					//fmt.Println("满足条件1", target, totalReward, min, max, len(results))
				}
			} else {
				//当前组合总共的奖励出去的金额
				totalReward := calculateTotalReward(target, minRewards, rewards, sumRewards)
				if totalReward >= maxRewards && totalReward <= minRewards {
					results = append(results, target)
					//fmt.Println("满足条件2", target, totalReward, min, max, len(results))
				}
			}
		}
		log.Logs().Info("结果的大小", len(results), "循环次数", i)
		if lft == 0 && rgt == 0 {
			break
		}
		if len(results) > 0 {
			break
		}
	}
	return
}

// 根据配置杀率和浮动比例得到开奖号码
func GEN_HORSE_Control(issue_num int64) []int64 {
	var TotalNum float64
	db1.Mysql().
		Table("home_order").
		Select("ifnull(sum(amount),0) as amount").
		Where("issue_num = ? ", issue_num).
		Find(&TotalNum)
	var rewards [10][10]float32

	ctx_init := context.Background()
	Openn_Issue := strconv.FormatInt(issue_num, 10)
	for i := 1; i <= 10; i++ {
		dataGetvalue := db1.Redis().HGet(ctx_init, Openn_Issue, fmt.Sprintf("%d", i))
		json.Unmarshal([]byte(dataGetvalue.Val()), &rewards[i-1])
	}
	var sumRewards map[int8]float32
	sumRewards = make(map[int8]float32)
	for i := 3; i <= 19; i++ {
		betlist_result := make([]float64, 10)
		dataGetvalue := db1.Redis().HGet(ctx_init, Openn_Issue, fmt.Sprintf("sum-%d", i))
		json.Unmarshal([]byte(dataGetvalue.Val()), &betlist_result)
		sumRewards[int8(i)] = float32(betlist_result[0])
	}
	//var rewardsList []model.HomeLotteryStatistic
	//db1.Mysql().
	//	Table(model.TableNameHomeLotteryStatistic).
	//	Where("open_issue_num = ?", issue_num).
	//	Find(&rewardsList)
	//
	//var sumRewardsList []model.HomeLotterySum
	//db1.Mysql().
	//	Table(model.TableNameHomeLotterySum).
	//	Where("open_issue_num = ?", issue_num).
	//	Find(&sumRewardsList)
	//
	//for index, value := range rewardsList {
	//	rewards[index][0] = float32(value.Champion)
	//	rewards[index][1] = float32(value.Second)
	//	rewards[index][2] = float32(value.Third)
	//	rewards[index][3] = float32(value.Fourth)
	//	rewards[index][4] = float32(value.Fifth)
	//	rewards[index][5] = float32(value.Sixth)
	//	rewards[index][6] = float32(value.Seventh)
	//	rewards[index][7] = float32(value.Eighth)
	//	rewards[index][8] = float32(value.Ninth)
	//	rewards[index][9] = float32(value.Tehth)
	//}
	//
	//for _, value := range sumRewardsList {
	//	sumRewards[int8(value.ChampionSecond)] = float32(value.Amount)
	//}
	var genereate Generate
	data := genereate.OpenNew(float32(TotalNum), rewards, sumRewards)
	return data
}

// 开奖逻辑 计算号码 不能重复 不能连续
func (t *Generate) OpenNew(total float32, rewards [10][10]float32, sumRewards map[int8]float32) []int64 {
	horses := []int8{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	//该轮平台总收益=用户下注的总金额
	//var total float32
	//10*10该轮的累计赔付金额
	//var rewards [10][10]float32
	//冠亚和该轮累计赔付金额
	//var sumRewards map[int8]float32
	//系统配置的砂率
	var kill_rate string
	db1.Mysql().Debug().Table("home_config").Select("config_value").
		Where("config_key =? ", "kill_rate").Find(&kill_rate)

	var min = DEFAULT_KILL_MIN
	var max = DEFAULT_KILL_MAX
	var lft = DEFAULT_LEFT_OFFSET
	var rgt = DEFAULT_RIGHT_OFFSET
	if strings.Contains(kill_rate, ",") {
		killConfig := strings.Split(kill_rate, ",")
		if len(killConfig) == 4 {
			min, _ = strconv.Atoi(killConfig[0])
			max, _ = strconv.Atoi(killConfig[1])
			lft, _ = strconv.Atoi(killConfig[2])
			rgt, _ = strconv.Atoi(killConfig[3])
		} else {
			log.Logs().Info("杀率配置错误1：", min, max, lft, rgt)
		}
	} else {
		log.Logs().Info("杀率配置错误2：", min, max, lft, rgt)
	}

	//有没有计算的结果
	if len(combArray) < DEFAULT_OFFSET_ARR {
		log.Logs().Info("enter.....combArray")
		combArray = permutations(horses)
	}

	var FinalResult []int64
	//Info, ok := targetMaps[0]
	if max == 1 && min == 0 && lft == 0 && rgt == 0 {
		randNum := rand.Intn(3567222)
		for _, value := range combArray[randNum] {
			FinalResult = append(FinalResult, int64(value))
		}
		log.Logs().Info("开奖---完全随机号码：", FinalResult, "mapSize:", len(combArray), "随机的索引:", randNum)
	} else {
		targetMaps := findInRange(combArray, total, rewards, sumRewards, min, max, lft, rgt)
		mapSize := len(targetMaps)
		if mapSize == 0 {
			randNum := rand.Intn(3567222)
			for _, value := range combArray[randNum] {
				FinalResult = append(FinalResult, int64(value))
			}
			log.Logs().Info("开奖---不满足杀率随机号码：", FinalResult, "mapSize:", mapSize, "随机的索引:", randNum)
		} else {
			ok := rand.Intn(mapSize - 1)
			for _, value := range targetMaps[ok] {
				FinalResult = append(FinalResult, int64(value))
			}
			log.Logs().Info("开奖---满足杀率号码：", FinalResult, "mapSize:", mapSize, "随机的索引:", ok)
		}
	}
	return FinalResult

	/*for _, valueList := range targetMaps {
		for _, value := range valueList {
			FinalResult = append(FinalResult, int64(value))
		}
		if len(valueList) == STANDARD_LENGTH {
			break
		}
	}*/

	/*if len(FinalResult) == 0 {
		res := []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
		Shuffle(res, rand.New(rand.NewSource(time.Now().Unix())))
		FinalResult = res
	}*/

	//没有就随机产生
	/*if len(targetMaps) == 0 {
		log.Logs().Warn("===========>FORCE RANDOM<=================")
		return t.Open()
	} else {
		log.Logs().Warn("===========>FORCE HAVE MAP<=================")
		var FinalResult []int64
		//Info, ok := targetMaps[0]
		for _, valueList := range targetMaps {
			for _, value := range valueList {
				FinalResult = append(FinalResult, int64(value))
			}
			if len(valueList) == STANDARD_LENGTH {
				break
			}
		}
		return FinalResult
	}*/
}

// arr 是需要打乱顺序的数组
// r 是伪随机数生成器
func Shuffle(arr []int64, r *rand.Rand) {
	for i := len(arr) - 1; i > 0; i-- {
		j := r.Intn(i + 1)
		arr[i], arr[j] = arr[j], arr[i]
	}
}

// 是否倒序或者顺序的自然数
func ConsecutiveNumbers(arr []int8) bool {
	inr := []int8{}
	sub := []int8{}
	for i := 0; i < len(arr); i++ {
		if i == 0 || arr[i] != arr[i-1]+1 {
			inr = append(inr, arr[i])
		}
		if i == 0 || arr[i] != arr[i-1]-1 {
			sub = append(sub, arr[i])
		}
	}
	if len(inr) > 3 || len(sub) > 3 {
		return true
	}
	return false
}

// 随机开奖号码逻辑
func (t *Generate) Open() []int64 {
	//probability := util.RandInterval(1, 50)
	//暂时没有使用的
	/*amount := float64(0)
	betItemInfo := BetItemInfo{}
	for _, v := range betItemInfo.Data {
		amount += float64(v.Id)
	}*/
	openNumber, _ := collection.NewInt64Collection([]int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Shuffle().ToInt64s()
	input := []int8{1, 2, 3, 5, 6, 8, 9, 10}
	ConsecutiveNumbers(input)

	inputInt := []int{1, 2, 3, 5, 6, 8, 9, 10}
	bool := kgo.KNum.IsNaturalRange(inputInt, true)
	if bool {
		return nil
	} else {
		return openNumber
	}
}

// 下注数据
func (t *Generate) GetBetData(langinfo string) pb.G1RoomInfoResponse {
	if langinfo == "" {
		langinfo = "en"
	}
	userlang := TotalLangMap[langinfo]
	var fixodds float64
	fixodds = 0.97

	g1RoomInfoResponse := pb.G1RoomInfoResponse{}
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "11", Label: userlang["BigItem"][11]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "1", Label: userlang["BigItem"][1]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "2", Label: userlang["BigItem"][2]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "3", Label: userlang["BigItem"][3]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "4", Label: userlang["BigItem"][4]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "5", Label: userlang["BigItem"][5]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "6", Label: userlang["BigItem"][6]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "7", Label: userlang["BigItem"][7]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "8", Label: userlang["BigItem"][8]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "9", Label: userlang["BigItem"][9]})
	g1RoomInfoResponse.BetData = append(g1RoomInfoResponse.BetData, &pb.G1RoomInfoResponse_BetItemInfo{Id: "10", Label: userlang["BigItem"][10]})
	for k, v := range g1RoomInfoResponse.BetData {
		if v.Id == "11" {
			tmpValue, _ := decimal.NewFromFloat(43.23).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-3", Label: "3", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(43.23).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-4", Label: "4", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(20.7).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-5", Label: "5", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(20.7).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-6", Label: "6", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(13.6).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-7", Label: "7", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(13.6).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-8", Label: "8", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(10.54).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-9", Label: "9", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(10.54).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-10", Label: "10", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(8.27).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-11", Label: "11", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(10.54).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-12", Label: "12", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(10.54).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-13", Label: "13", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(13.6).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-14", Label: "14", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(13.6).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-15", Label: "15", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(20.7).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-16", Label: "16", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(20.7).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-17", Label: "17", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(43.23).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-18", Label: "18", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(43.23).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-19", Label: "19", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(2.25).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-101", Label: userlang["SmallItem"][101], Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(1.8).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-102", Label: userlang["SmallItem"][102], Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(1.8).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-103", Label: userlang["SmallItem"][103], Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(2.25).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-104", Label: userlang["SmallItem"][104], Multiple: tmpValue})
		} else {
			tmpValue, _ := decimal.NewFromFloat(10).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-1", Label: "1", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-2", Label: "2", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-3", Label: "3", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-4", Label: "4", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-5", Label: "5", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-6", Label: "6", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-7", Label: "7", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-8", Label: "8", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-9", Label: "9", Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-10", Label: "10", Multiple: tmpValue})

			tmpValue, _ = decimal.NewFromFloat(2).Mul(decimal.NewFromFloat(fixodds)).RoundFloor(2).Float64()
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-101", Label: userlang["SmallItem"][101], Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-102", Label: userlang["SmallItem"][102], Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-103", Label: userlang["SmallItem"][103], Multiple: tmpValue})
			g1RoomInfoResponse.BetData[k].Data = append(g1RoomInfoResponse.BetData[k].Data, &pb.G1RoomInfoResponse_BetItemInfo_BetItemSubInfo{Id: v.Id + "-104", Label: userlang["SmallItem"][104], Multiple: tmpValue})
		}
	}
	return g1RoomInfoResponse
}

// 获取奖励数据
func (t *Generate) GetAwardData(arr []int64) map[string]float64 {
	betData := t.GetBetData("").BetData
	m := map[string]float64{}
	for _, v := range betData {
		for _, v1 := range v.Data {
			m[v1.Id] = v1.Multiple
		}
	}
	b := []string{}
	for k, v := range arr {
		//名次
		k1 := strconv.Itoa(k + 1)
		k2 := strconv.FormatInt(v, 10)
		b = append(b, k1+"-"+k2)
		//大小
		if v > 5 {
			b = append(b, k1+"-"+"101") //大
		} else {
			b = append(b, k1+"-"+"102") //小
		}
		//单双
		if v%2 != 0 {
			b = append(b, k1+"-"+"103") //单
		} else {
			b = append(b, k1+"-"+"104") //双
		}
	}
	//冠亚和
	sum := arr[0] + arr[1]
	b = append(b, "11"+"-"+strconv.FormatInt(arr[0]+arr[1], 10))
	if sum > 11 {
		b = append(b, "11"+"-"+"101") //大
	} else {
		b = append(b, "11"+"-"+"102") //小
	}
	if sum%2 != 0 {
		b = append(b, "11"+"-"+"103") //单
	} else {
		b = append(b, "11"+"-"+"104") //双
	}
	coll := collection.NewStrCollection(b)
	for k, _ := range m {
		if coll.ContainsCount(k) <= 0 {
			delete(m, k)
		}
	}
	return m
}
